#/bin/env python

import re
import unittest
import filecmp
import os
import sys
#
# Expose assert* from unittest.TestCase
# - give them pep8 style names
#
#[ssert_almost_equal', 'assert_almost_equals', 'assert_dict_contains_subset', 'assert_dict_equal', 'assert_equal', 'assert_equals', 'assert_false', 'assert_greater', 'assert_greater_equal', 'assert_in', 'assert_is', 'assert_is_instance', 'assert_is_none', 'assert_is_not', 'assert_is_not_none', 'assert_items_equal', 'assert_less', 'assert_less_equal', 'assert_list_equal', 'assert_multi_line_equal', 'assert_not_almost_equal', 'assert_not_almost_equals', 'assert_not_equal', 'assert_not_equals', 'assert_not_in', 'assert_not_is_instance', 'assert_not_regexp_matches', 'assert_raises', 'assert_raises_regexp', 'assert_regexp_matches', 'assert_sequence_equal', 'assert_set_equal', 'assert_true', 'assert_tuple_equal]

__all__ = ['assert_file_equal','expect_exsits']
caps = re.compile('([A-Z])')

def expect_exsits(*path):
    retval = True
    if len(path) == 0 :
        print 'None'
    else :
        for file in path:
            if not os.path.exists(file):
                print >> sys.stderr, "%s not exists" % file
                retval = False
    return retval  

def assert_file_equal(file1, file2):
    assert_true(filecmp.cmp(file1, file2))

def pep8(name):
    return caps.sub(lambda m: '_' + m.groups()[0].lower(), name)

class Dummy(unittest.TestCase):
    def nop():
        pass
_t = Dummy('nop')

for at in [ at for at in dir(_t)
            if at.startswith('assert') and not '_' in at ]:
    pepd = pep8(at)
    vars()[pepd] = getattr(_t, at)
    __all__.append(pepd)

del Dummy
del _t
del pep8
